package com.vcg.filters;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

public class CostFilter implements GlobalFilter {


    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        System.out.println("  CostFilter 过滤器 " + this.getClass().getSimpleName());
        // 在then方法里的，相当于aop中的后置通知
        return chain.filter(exchange).then(Mono.fromRunnable(() -> {
            System.out.println("  CostFilter 过滤器" + this.getClass().getSimpleName());
        }));
    }

}
